#!/usr/bin/env python
#-*-coding:utf-8-*-
# ---------------------------------
# create-time:      <2009/04/01 02:38:17>
# last-update-time: <halida 04/01/2009 11:21:53>
# ---------------------------------
# this is a tree view --technical prepare for 2.0 project

from qtlib import *

def test1():
    dm = QDirModel()
    tree = QTreeView()

    tree.setModel(dm)
    tree.show()
    run()

class TempModel(QAbstractItemModel):
    def init(self):
        pass
    def columnCount(self,index=None):
        return 2
    def rowCount(self,index=None):
        if not index:
            return 3
        return 0
    def data(self,index,role):
        return QVariant()
    def flags(self,index):
        return Qt.ItemFlags
    def headerData(self,section,orientation,role = Qt.DisplayRole):
        return QVariant()
    def index(self,row,column,parent=None):
        return QModelIndex()
    def parent(self,index):
        return QModelIndex()

class MyModel(QAbstractItemModel):
    def init(self):
        pass
    def columnCount(self,index=None):
        return 2
    def rowCount(self,index=None):
        if not index:
            return 3
        return 2
    def data(self,index,role):
        if role == Qt.DisplayRole:
            return QString("hah")
        return QVariant()

    def flags(self,index):
        return Qt.ItemFlags
    def tempheaderData(self,section,orientation,role = Qt.DisplayRole):
        if role == Qt.DisplayRole:
            return QString(unicode(section))
        return QVariant()
    def index(self,row,column,parent=None):
        return QModelIndex()
    def parent(self,index):
        return QModelIndex()

def test2():
    dm = MyModel();dm.init()
    tree = QTreeView()

    tree.setModel(dm)
    tree.show()
    run()

def main():
    test2()

if __name__=="__main__":
    main()
